package com.carpedil.shirodemo.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.carpedil.shirodemo.system.model.RoleMenu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * Mapper 接口
 *
 * @author carpedil
 * @since 2021-01-05
 */
@Repository
public interface RoleMenuMapper extends BaseMapper<RoleMenu> {
  /**
   * getMenusByRoleId
   *
   * @param roleId roleId
   * @return Integer[]
   */
  @Select("select menu_id from role_menu where role_id = #{roleId}")
  Integer[] getMenusByRoleId(@Param("roleId") Integer roleId);

  /**
   * insertRoleMenus
   *
   * @param roleId roleId
   * @param menuIds menuIds
   */
  void insertRoleMenus(@Param("roleId") Integer roleId, @Param("menuIds") Integer[] menuIds);

  /**
   * deleteByRoleId
   *
   * @param roleId roleId
   */
  @Delete("delete from role_menu where role_id = #{roleId}")
  void deleteByRoleId(@Param("roleId") Integer roleId);
}
